import React from 'react';
import { getPositionTypeList } from '@/services/organization';

const useJobList = () => {
    const [data, setData] = React.useState([]);
    const [loading, setLoading] = React.useState(false);

    const fetchData = async () => {
        setLoading(true);

        const { data: d, code } = (await getPositionTypeList()) || {};

        if (code === 10000) {
            setData(d);
        }

        setLoading(false);
    };

    React.useEffect(() => {
        fetchData();
    }, []);

    return [loading, data, fetchData];
};

export default useJobList;
